﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GPTB2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
          
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int a, b, c;
            a = int.Parse(textBox1.Text);
            b = int.Parse(textBox2.Text);
            c = int.Parse(textBox3.Text);

            double delta = 0;
            delta = b * b - 4 * a * c;
            string kq = "";

            double x1, x2 = 0;
            if
             (textBox1.Text == "")
            {
                MessageBox.Show("LapKan Product – Coder: Huygamer");
            }
            else if
                    (textBox2.Text == "")
            {
                MessageBox.Show("LapKan Product – Coder: Huygamer");
            }
            else if
              (textBox3.Text == "")
            {
                MessageBox.Show("LapKan Product – Coder: Huygamer");
            }
            else if
            (delta > 0)
            {
                x1 = (-b + Math.Sqrt(delta)) / (2 * a);
                x2 = (-b - Math.Sqrt(delta)) / (2 * a);
                kq = " Phương Trình CÓ 2 Nghiệm là : x1 = " + x1 + ", X2 = " + x2;
            }
            else if (delta == 0)
            {
                kq = "Phương trình có nghiệm kép là :  X1 = X2 = " + x2;
            }
            else
            {
                kq = "Phương Trình Vô Nghiệm";
            }

            label7.Text = textBox1.Text + "X^2 +  " + textBox2.Text + "X + " + textBox3.Text + " = 0 ";
            label6.Text = kq;
            textBox1.Text = "0";
            textBox2.Text = "0";
            textBox3.Text = "0";


        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
